//
//  YahooGroup.m
//  HelloWorld
//
//  Created by Martin Le C. on 5/12/09.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "YahooGroup.h"


@implementation YahooGroup
@synthesize name;
@synthesize open;
@synthesize users;
- (id) init:(NSString*)n o:(BOOL)o {
	self.name=n;  
	self.open=o;
	self.users = [NSMutableArray new];
	return self;
}
- (id) init:(NSString*)n {
	return [self init:n o:YES];
}
- (void) addUser:(YahooUser*)yu {
	[[self users] addObject:yu];
}
- (void) removeUserAt:(NSInteger)i {
	[[self users] removeObjectAtIndex:i];
}
- (BOOL) isEmpty {
	return ([self.users count] <= 0);
}
- (NSString *) toURIString {
	return [NSString stringWithFormat:@"name=%@ open?=%@", self.name, self.open];
}
- (YahooUser*) getUserAt:(int)i { 
	return (YahooUser*)[users objectAtIndex:i]; 
}
- (NSInteger) countUsers {
	return [users count];
}
- (NSInteger) getIndexOfFriend:(NSString*)userId {
	NSInteger a;
	for (NSUInteger i=0; i<[self.users count]; i++) {
		if([[self.users objectAtIndex:i] yahooId] == userId) 
		a = i;
	}
	return a;
}
@end